package site.marqstree.kotlin.library.base.util.photo

import android.app.Activity
import android.net.Uri
import com.bigkoo.alertview.AlertView
import com.bigkoo.alertview.OnItemClickListener
import com.blankj.utilcode.util.PathUtils
import com.blankj.utilcode.util.TimeUtils
import org.devio.takephoto.app.TakePhoto
import org.devio.takephoto.app.TakePhotoImpl
import org.devio.takephoto.compress.CompressConfig
import site.marqstree.kotlin.library.base.common.AppManager
import site.marqstree.kotlin.library.base.util.qiniu.IQiniu
import site.marqstree.kotlin.library.base.util.qiniu.QiniuUtil
import java.io.File


/*
 * 项目名: KotlinMall
 * 包名: site.marqstree.kotlin.library.base.util
 * 文件名: PhotoUtil
 * 创建者: marqstree
 * 创建时间: 2020/3/5 10:58
 * 描述: TODO
 */
class PhotoUtil private constructor() {
    //
    //private lateinit var mLocalFileListener:ITakePhoto
    //private lateinit var mRemoteFileListener:IQiniu
    //private var mActivity:Activity = AppManager.instance.currentActivity()
    //
    //private val mTakePhotoResultListener by lazy{
    //    TakePhotoResultListener(mLocalFileListener)
    //}
    //private val mTakePhoto: TakePhoto by lazy{
    //    TakePhotoImpl(mActivity,mTakePhotoResultListener)
    //}
    //
    //
    //private var mLocalFileUrl:String? = null
    //private var mRemoteFileUrl:String? = null
    //
    //private fun showTakePhotoView() {
    //    //或者builder模式创建
    //    AlertView.Builder()
    //        .setContext(this)
    //        .setStyle(AlertView.Style.ActionSheet)
    //        .setTitle("选择图片")
    //        .setMessage(null)
    //        .setCancelText("取消")
    //        .setDestructive("拍照", "从相册中选择")
    //        .setOthers(null)
    //        .setOnItemClickListener(object: OnItemClickListener {
    //            override fun onItemClick(o: Any?, position: Int) {
    //                mTakePhoto.onEnableCompress(CompressConfig.ofDefaultConfig(),false)
    //                when(position){
    //                    0 -> {
    //                        mTakePhoto.onPickFromCapture(Uri.fromFile(mTempFile))
    //                    }
    //                    1 -> mTakePhoto.onPickFromGallery()
    //                }
    //            }
    //
    //        })
    //        .build()
    //        .show()
    //}
    //
    //companion object{
    //    fun builder():Builder{
    //        return Builder()
    //    }
    //}
    //
    //class Builder(){
    //    private val mPhotoUtil = PhotoUtil()
    //
    //    fun setActivity(activity: Activity):Builder{
    //        mPhotoUtil.mActivity = activity
    //        return this
    //    }
    //
    //    fun setLocalFileListner(listener: ITakePhoto):Builder{
    //        mPhotoUtil.mLocalFileListener = listener
    //        return this
    //    }
    //
    //    fun setRemoteFileListener(listner: IQiniu):Builder{
    //        mPhotoUtil.mRemoteFileListener = listner
    //        return this
    //    }
    //
    //    fun takeLocalPhoto() {
    //        mPhotoUtil.showTakePhotoView()
    //    }
    //
    //    fun takeRemotePhoto() {
    //        mPhotoUtil.mLocalFileListener = object :ITakePhoto{
    //            override fun success(localFileUrl: String) {
    //                QiniuUtil(localFileUrl,
    //                        mPhotoUtil.mRemoteFileListener)
    //                    .uploadFile()
    //            }
    //        }
    //        mPhotoUtil.showTakePhotoView()
    //    }
    //}

}